#if !defined(__VIDEORECORDER_H_)
#define __VIDEORECORDER_H_

typedef struct {
    int m_iVideoResolution;
    int m_iFrameRate;
    int m_iZoom;
    int m_iBrightness;
    int m_iContrast;
    int m_iSharpness;
    int m_iWhiteBalance;
    int m_iColorMode;
    int m_iSceneMode;
    int m_iDirection;
    int m_iFlash;
    int m_iISO;
    int m_iExposureCompensation;
} VideoRecorderFormat;


class VideoRecorder
{
private:
    unsigned long       m_ulRecordFrameWidth;
    unsigned long       m_ulRecordFrameHeight;

    unsigned int        m_uOutFrameID;    // Current Frame ID for output data
    unsigned int        m_uInFrameID;     // Current Frame ID for input data

    IEvent             *m_pFrameCopyEvent;

    BYTE               *m_pRecordFramedBuf;
    unsigned long       m_ulRecordBufFrameLen;

    VideoRecorderFormat m_RecorderFormat;

    FrameCapture       *m_pCapture;

    FrameDisplay       *m_pShower;

    RGB2YCbCrConverter *m_pConverter;

    HANDLE              m_hRecordLock;

private:
    void  InitVideoRecorderFormat();

    void  ResolutionToSize(int Resolution,
                          unsigned long *pWidth,
                          unsigned long *pHeight);

    ECode SetRecordSize();

    BOOL  BuildRecordBuffer();

    void  GetRecordDest(YCbCrBufferInfo *pYCbCrInfo);


public:
    BOOL  Initialize(FrameCapture *pCap,
                     FrameDisplay *pShower,
                     RGB2YCbCrConverter *pConverter);

    void  Destroy();

    ECode GetVideoRecorderFormat(unsigned int nID,
                                 int *pwParam,
                                 int *plParam);

    ECode SetVideoRecorderFormat(unsigned int nID,
                                 int wParam,
                                 int lParam);

    ECode BeginRecord(IEvent ** ppOutEvent);

    void  DoRecord(void *pFrameBuffer);

    ECode StopRecord();

    ECode GetRecordFrame(Camera_ImageFrame* pFrame);

};

#endif //__VIDEORECORDER_H_
